using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Tools;
using Pixysoft.Framework.Verifications;
using Pixysoft.Framework.Noebe;
using Pixysoft.Weblications.Sango.Entities;
using Pixysoft.Weblications.Sango.Constant;

namespace Pixysoft.Weblications.Sango.Environment
{
    public class EqmEquipmentHelper
    {
        private static List<Eqm_Equipment> orms = new List<Eqm_Equipment>();

        public static void initialize()
        {
            orms = SettingHelper.GetNoebe().EntityNoebeCommand.Select<Eqm_Equipment>();

            LoggerHelper.Info("initialize Eqm_Equipment.count:{0}", orms.Count);
        }

        public static List<Eqm_Equipment> searchAll()
        {
            return orms;
        }

        public static Eqm_Equipment searchBySerialcode(long serialCode)
        {
            foreach (Eqm_Equipment orm in orms)
            {
                if (serialCode == orm.Equipmentserialcode)
                    return orm;
            }

            throw Exceptions.VerificationFailedException(serialCode);
        }

        public static List<Eqm_Equipment> searchShopEqms(long level)
        {
            List<Eqm_Equipment> list = new List<Eqm_Equipment>();

            foreach (Eqm_Equipment orm in orms)
            {
                if (orm.Placetypecode != EqmPlaceTypecodeCollection.SHOP)
                    continue;

                if (orm.Visiblelevel > level)
                    continue;

                list.Add(orm);
            }

            return list;
        }

    }
}